Skip to content

Conversation

gururaj1512
Copy link
Member

Resolves None

Description

What is the purpose of this pull request?

This pull request:

  • feat: add ndarray/base/binary-input-casting-dtype

Related Issues

Does this pull request have any related issues?

This pull request:

  • resolves None

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@gururaj1512 gururaj1512 added GSoC Google Summer of Code. gsoc: 2025 Google Summer of Code (2025). labels Aug 17, 2025
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 17, 2025
@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
ndarray/base/binary-input-casting-dtype $\color{red}141/148$
$\color{green}+95.27\%$
$\color{red}26/29$
$\color{green}+89.66\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{red}141/148$
$\color{green}+95.27\%$

The above coverage report was generated for the changes in this PR.

@gururaj1512
Copy link
Member Author

Currently the examples are failing. But it can be tackled through

function safeInputCastingDataType( dtype1, dtype2, dtype3, policy ) {
	try {
		return inputCastingDataType( dtype1, dtype2, dtype3, policy );
	} catch ( error ) {
		if ( policy === 'none' && ( dtype1 !== dtype2 || dtype2 !== dtype3 ) ) {
			return 'incompatible';
		}
		return error;
	}
}

// Resolve casting data types:
logEachMap( 'dtypes: (%10s, %10s, %10s). policy: %20s. result: %10s.', args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ], naryFunction( safeInputCastingDataType, 4 ) );

Is above method correct? Or do we have similar packages/method to perform it?

@kgryte kgryte added the Feature Issue or pull request for adding a new feature. label Aug 28, 2025
var inputCastingDataType = require( './../lib' );

// Get the list of real-valued data types:
var dt = dtypes( 'real' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gururaj1512 Rather than dynamically generating the list as you do here, how about just hardcoding idt1, idt2, and odt with data types which are known to succeed according to the listed policies? E.g.,

var idt1 = [
    'float32',
    'float64'
];

var idt2 = [
    'int8',
    'uint8'
];

var odt = [
    'float32',
    'float64',
    'complex64',
    'complex128'
];

In short, can you engineer some combinations which work, rather than using the most generalized approach?

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Issue or pull request for adding a new feature. GSoC Google Summer of Code. gsoc: 2025 Google Summer of Code (2025). Needs Changes Pull request which needs changes before being merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants